﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace TestEFAbstractEntity1.Migrations
{
    public partial class V1001 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "WorkNodes",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    NextNodeId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    CountersignNodeId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    Discriminator = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ParalleNodeId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    ApprovalUser = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WorkNodes", x => x.Id);
                    table.ForeignKey(
                        name: "FK_WorkNodes_WorkNodes_CountersignNodeId",
                        column: x => x.CountersignNodeId,
                        principalTable: "WorkNodes",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_WorkNodes_WorkNodes_NextNodeId",
                        column: x => x.NextNodeId,
                        principalTable: "WorkNodes",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_WorkNodes_WorkNodes_ParalleNodeId",
                        column: x => x.ParalleNodeId,
                        principalTable: "WorkNodes",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_WorkNodes_CountersignNodeId",
                table: "WorkNodes",
                column: "CountersignNodeId");

            migrationBuilder.CreateIndex(
                name: "IX_WorkNodes_NextNodeId",
                table: "WorkNodes",
                column: "NextNodeId");

            migrationBuilder.CreateIndex(
                name: "IX_WorkNodes_ParalleNodeId",
                table: "WorkNodes",
                column: "ParalleNodeId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "WorkNodes");
        }
    }
}
